package com.grm.j002linkedlist;

public class MyLinkedList {
    private Node head;

    public void add(Object value) {
        Node node = new Node(value);
        if (head == null) {
            head = node;
        } else {
            Node current = head;
            while (current.getNext() != null) { // 遍历至当前需要添加的节点
                current = current.getNext();
            }
            current.setNext(node);
        }
    }

    void delete(Node e) {

    }

    void print() {
        Node current = head; // 从头节点开始遍历
        while (current != null) {
            System.out.print(current.getVal() + " ");
            current = current.getNext();
        }
        System.out.println();
    }
}
